//
//  SYS_SelectShipAddressCell.m
//  System_App
//
//  Created by 吴健 on 2017/12/6.
//  Copyright © 2017年 czy001. All rights reserved.
//

#import "SYS_SelectShipAddressCell.h"

@interface SYS_SelectShipAddressCell ()
{
    IBOutlet UILabel *lb_title;
    IBOutlet UILabel *lb_default;
    IBOutlet UILabel *lb_address;
    IBOutlet NSLayoutConstraint *lc_addressHeight;
}
@end

@implementation SYS_SelectShipAddressCell

+ (SYS_SelectShipAddressCell *)getSelectShipAddressCell{
    SYS_SelectShipAddressCell *cell = nil;
    NSArray *objects = [[NSBundle mainBundle] loadNibNamed:@"SYS_SelectShipAddressCell" owner:self options:nil];
    for (NSObject *obj in objects) {
        if ([obj isKindOfClass:[SYS_SelectShipAddressCell class]]) {
            cell = (SYS_SelectShipAddressCell *)obj;
            break;
        }
    }
    return cell;
}

// iOS 11的 margins
- (UIEdgeInsets)layoutMargins {
    [super layoutMargins];
    return UIEdgeInsetsMake(0, 0, 0, 0);
}

- (void)setIndexPath:(NSIndexPath *)indexPath{
    _indexPath = indexPath;
    lb_default.hidden = !(_indexPath.row == 0);
    lb_title.text = FORMAT(@"地址%ld", _indexPath.row + 1);
}

- (void)setModel:(AddressList *)model{
    _model = model;
    
    lb_address.text = [NSString stringWithFormat:@"%@%@%@%@",model.provinceName,model.cityName,model.areaName,_model.detailLocation];
    lb_address.numberOfLines = 0;
    lc_addressHeight.constant = [DSUtility heightOfString:lb_address.text font:DSFONT_DETAIL width:SCREENWIDTH-32 maxHeight:999];
    [self updateConstraints];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
